package com.hospital.tools;

import java.lang.reflect.Field;

import org.w3c.dom.Text;


import com.hospital.activity.R;

import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.widget.EditText;
import android.widget.TextView;

public class MyDialogBuilder {


	public AlertDialog getPasswordChangeDialog(Context in,android.content.DialogInterface.OnClickListener clik,View v){

		AlertDialog.Builder b=new Builder(in);
		//View v=LayoutInflater.from(in).inflate(R.layout.passwordchangedialog,null);

		b.setTitle("修改密码");
		b.setPositiveButton("修改密码", clik);
		b.setNegativeButton("取消", new OnClickListener() {

			@Override
			public void onClick(DialogInterface dialog, int which) {
				// TODO Auto-generated method stub
				try {
					Field field = dialog.getClass().getSuperclass().getDeclaredField("mShowing");
					field.setAccessible(true);
					field.set(dialog, true);
				} catch (Exception e) {
					e.printStackTrace();
				}
				dialog.dismiss();
			}
		});
		b.setView(v);
		return b.create();
	}

	public AlertDialog getPasswordFindDialog(Context in,android.content.DialogInterface.OnClickListener clik,View v){

		AlertDialog.Builder b=new Builder(in);
		//View v=LayoutInflater.from(in).inflate(R.layout.passwordchangedialog,null);

		b.setTitle("找回密码");
		b.setPositiveButton("找回密码", clik);
		b.setNegativeButton("取消", new OnClickListener() {

			@Override
			public void onClick(DialogInterface dialog, int which) {
				// TODO Auto-generated method stub
				try {
					Field field = dialog.getClass().getSuperclass().getDeclaredField("mShowing");
					field.setAccessible(true);
					field.set(dialog, true);
				} catch (Exception e) {
					e.printStackTrace();
				}
				dialog.dismiss();
			}
		});
		b.setView(v);
		return b.create();
	}
	public AlertDialog showPasswordDialog(Context in , String mes){

		AlertDialog.Builder b=new Builder(in);
		View v=LayoutInflater.from(in).inflate(R.layout.showpassworddialog,null);

		b.setTitle("返回密码");
		TextView e = (TextView)v.findViewById(R.id.showPasswordText);
		e.setText(mes);
		b.setNegativeButton("确定", new OnClickListener(){

			@Override
			public void onClick(DialogInterface dialog, int which) {
				// TODO Auto-generated method stub
				dialog.dismiss();
			}

		});

		b.setView(v);
		return b.create();
	}
	public AlertDialog getSMSErrorDialog( final Context in){
		AlertDialog.Builder b=new Builder(in);
		b.setTitle("失败");
		b.setMessage("发送失败，可能短信已被人为读取，请手动回复确认码！");
		b.setNegativeButton("取消", new OnClickListener() {

			@Override
			public void onClick(DialogInterface dialog, int which) {
				// TODO Auto-generated method stub
				dialog.dismiss();
			}
		});
		b.setPositiveButton("登录", new OnClickListener() {

			@Override
			public void onClick(DialogInterface dialog, int which) {
				// TODO Auto-generated method stub
				Intent i=new Intent();
			//	i.setClass(in, LoginAct.class);
		//		in.startActivity(i);
				dialog.dismiss();
			}
		});
		return b.create();
	}

	//
	public AlertDialog bulidingDialog(final Context in){

		AlertDialog.Builder b=new Builder(in);
		//View v=LayoutInflater.from(in).inflate(R.layout.passwordchangedialog,null);

		b.setTitle("建设中");
		b.setMessage("建设中，敬请期待...");
		b.setNegativeButton("确定", new OnClickListener() {

			@Override
			public void onClick(DialogInterface dialog, int which) {
				// TODO Auto-generated method stub
				dialog.dismiss();
			}
		});

		return b.create();
	}



	public AlertDialog getLonginDialog(final Context in){
		AlertDialog.Builder b=new Builder(in);
		b.setTitle("用户未登录");
		b.setMessage("现在是否要登录？");
		b.setNegativeButton("取消", new OnClickListener() {

			@Override
			public void onClick(DialogInterface dialog, int which) {
				// TODO Auto-generated method stub
				dialog.dismiss();
			}
		});

		b.setPositiveButton("登录", new OnClickListener() {

			@Override
			public void onClick(DialogInterface dialog, int which) {
				// TODO Auto-generated method stub
				Intent i=new Intent();
			//	i.setClass(in, LoginAct.class);
		//		in.startActivity(i);
			}
		});
		return b.create();
	}



}
